﻿using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Messaging;
using NicoView.Model;
using NicoView.Model.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace NicoView.ViewModel
{
    public abstract class NicoViewViewModelBase:ViewModelBase,IDisposable
    {
        public NicoViewViewModelBase()
        {
            ApplicationDispatcher = NicoViewApplicationDispatcher.Current;

            this.InternalApplication.Property.PropertyChanged += (s, e) =>
            {
                this.RaisePropertyChanged(e.PropertyName);
            };

            this.InternalApplication.PropertyChanged += (s, e) =>
            {
                this.RaisePropertyChanged(e.PropertyName);
            };
        }


        public bool IsEnabled
        {
            get
            {
                return this.InternalApplication.IsEnabled;
            }
        }


        public NicoViewApplicationDispatcher ApplicationDispatcher
        {
            get;
            private set;
        }

        public NicoViewApplication InternalApplication
        {
            get
            {
                return NicoViewApplication.Current;
            }
        }


        /// <summary>
        /// すべてのプロパティが変更されたことを通知
        /// </summary>
        public void RaisePropertyChangedAll()
        {
            this.RaisePropertyChanged("");

        }


        protected virtual void OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            this.RaisePropertyChangedAll();
        }
        


        public void Dispose()
        {
            
        }
    }
}
